﻿<UserControl x:Class="GW2PAO.Views.DungeonTracker.DungeonView"
             xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
             xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
             xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006" 
             xmlns:d="http://schemas.microsoft.com/expression/blend/2008" 
             xmlns:i="http://schemas.microsoft.com/expression/2010/interactivity"
             xmlns:ei="http://schemas.microsoft.com/expression/2010/interactions"
             xmlns:converters="clr-namespace:GW2PAO.Style.Converters"
             xmlns:core="clr-namespace:GW2PAO.PresentationCore;assembly=GW2PAO.PresentationCore"
             mc:Ignorable="d" d:DesignHeight="35" d:DesignWidth="200"
             TextOptions.TextFormattingMode="Display">

    <UserControl.Resources>
        <ResourceDictionary>
            <ResourceDictionary.MergedDictionaries>
                <ResourceDictionary Source="../../Style/ResourceLibrary.xaml" />
            </ResourceDictionary.MergedDictionaries>

            <core:AutoRefreshCollectionViewSource Source="{Binding Paths}" x:Key="PathsCollection" />
            <Geometry x:Key="PathCheckboxGeometry">M 0 6 L 5 12 L 12 0 L 12 0</Geometry>
        </ResourceDictionary>
    </UserControl.Resources>

    <UserControl.ContextMenu>
        <ContextMenu>
            <MenuItem Header="Hide" Command="{Binding HideCommand}" />
            <Separator />
            <MenuItem Header="{Binding MinimumLevel}" IsEnabled="False" />
            <MenuItem Header="{Binding ZoneName}" IsEnabled="False" />
            <MenuItem Header="Copy Waypoint Code" Command="{Binding CopyWaypointCommand}" />
            <MenuItem Header="Open Wiki Page" Command="{Binding OpenWikiPageCommand}" />
        </ContextMenu>
    </UserControl.ContextMenu>

    <!--Note: DataContext is set by the DungeonTrackerView-->
    <Border CornerRadius="0" Margin="0,0,5,0" Padding="15,0,5,5" BorderThickness="0,0,0,1">

        <Border.BorderBrush>
            <LinearGradientBrush Opacity="0.65">
                <GradientStop Color="#FFFFA500" Offset="0.5"/>
                <GradientStop Color="#00FFA500" Offset="1"/>
            </LinearGradientBrush>
        </Border.BorderBrush>

        <Border.Background>
            <SolidColorBrush Color="#01FFFFFF" />
        </Border.Background>

        <Grid Margin="0,5,0,0">
            <Grid.RowDefinitions>
                <RowDefinition Height="Auto" />
            </Grid.RowDefinitions>
            <Grid.ColumnDefinitions>
                <ColumnDefinition Width="135" />
                <ColumnDefinition Width="*" />
            </Grid.ColumnDefinitions>

            <core:OutlinedTextBlock Name="DungeonName"
                                    Grid.Row="0" Grid.Column="0"
                                    VerticalAlignment="Center" HorizontalAlignment="Left"
                                    FontSize="13"
                                    Text="{Binding DungeonName}" />
            
            <ItemsControl Grid.Row="0" Grid.Column="1"
                          Margin="0,0,0,0"
                          ItemsSource="{Binding Source={StaticResource PathsCollection}}">

                <ItemsControl.ItemsPanel>
                    <ItemsPanelTemplate>
                        <StackPanel Orientation="Horizontal"/>
                    </ItemsPanelTemplate>
                </ItemsControl.ItemsPanel>

                <ItemsControl.ItemTemplate>
                    <DataTemplate>
                        <CheckBox Grid.Row="1" Grid.Column="1"
                           HorizontalAlignment="Right" VerticalAlignment="Bottom"
                           IsChecked="{Binding IsCompleted}">                            
                            <CheckBox.Style>
                                <Style TargetType="CheckBox">
                                    <Setter Property="Template">
                                        <Setter.Value>
                                            <ControlTemplate TargetType="{x:Type CheckBox}">
                                                <Grid Margin="10,0,0,0">
                                                    <core:OutlinedTextBlock VerticalAlignment="Center" HorizontalAlignment="Center"
                                                                            Fill="White" Stroke="Black" StrokeThickness="4" StrokeOpacity="0.75"
                                                                            FontSize="13" FontFamily="Gisha"
                                                                            Text="{Binding DisplayName}">
                                                        <core:OutlinedTextBlock.Style>
                                                            <Style TargetType="{x:Type core:OutlinedTextBlock}">
                                                                <Setter Property="Effect">
                                                                    <Setter.Value>
                                                                        <DropShadowEffect ShadowDepth="0"
                                                                                          Color="Goldenrod"
                                                                                          Opacity="0"
                                                                                          BlurRadius="15"/>
                                                                    </Setter.Value>
                                                                </Setter>
                                                                <Style.Triggers>
                                                                    <Trigger Property="IsMouseOver" Value="True">
                                                                        <Trigger.EnterActions>
                                                                            <BeginStoryboard>
                                                                                <Storyboard>
                                                                                    <DoubleAnimation To="1"
                                                                                                 Storyboard.TargetProperty="(Effect).Opacity"
                                                                                                 Duration="00:00:00.1"/>
                                                                                </Storyboard>
                                                                            </BeginStoryboard>
                                                                        </Trigger.EnterActions>
                                                                        <Trigger.ExitActions>
                                                                            <BeginStoryboard>
                                                                                <Storyboard>
                                                                                    <DoubleAnimation To="0"
                                                                                                 Storyboard.TargetProperty="(Effect).Opacity"
                                                                                                 Duration="00:00:0.1"/>
                                                                                </Storyboard>
                                                                            </BeginStoryboard>
                                                                        </Trigger.ExitActions>
                                                                    </Trigger>
                                                                </Style.Triggers>
                                                            </Style>
                                                        </core:OutlinedTextBlock.Style>
                                                    </core:OutlinedTextBlock>
                                                    <Grid x:Name="CompletedCheckmark" Visibility="Hidden" Opacity="0.75">
                                                        <Path HorizontalAlignment="Center" VerticalAlignment="Center"
                                                          Width="13" Height="13" SnapsToDevicePixels="False"
                                                          Stroke="Black" StrokeThickness="4" StrokeLineJoin="Round"
                                                          Data="{StaticResource PathCheckboxGeometry}" />
                                                        <Path HorizontalAlignment="Center" VerticalAlignment="Center"
                                                          Width="13" Height="13" SnapsToDevicePixels="False"
                                                          Stroke="Orange" StrokeThickness="2" StrokeLineJoin="Round"
                                                          Data="{StaticResource PathCheckboxGeometry}" />
                                                    </Grid>
                                                </Grid>

                                                <ControlTemplate.Triggers>
                                                    <Trigger Property="IsChecked" Value="True">
                                                        <Setter TargetName="CompletedCheckmark" Property="Visibility" Value="Visible" />
                                                    </Trigger>
                                                    <Trigger Property="IsChecked" Value="False">
                                                        <Setter TargetName="CompletedCheckmark" Property="Visibility" Value="Hidden" />
                                                    </Trigger>
                                                </ControlTemplate.Triggers>

                                            </ControlTemplate>
                                        </Setter.Value>
                                    </Setter>
                                </Style>
                            </CheckBox.Style>
                            <CheckBox.ToolTip>
                                <StackPanel Orientation="Vertical">
                                    <core:OutlinedTextBlock Fill="White" Stroke="Black" StrokeThickness="4" StrokeOpacity="0.75"
                                                            FontSize="12" FontFamily="Gisha"
                                                            Text="{Binding NickName}"/>
                                    <StackPanel Orientation="Horizontal">
                                        <core:OutlinedTextBlock Fill="White" Stroke="Black" StrokeThickness="4" StrokeOpacity="0.75"
                                                                FontSize="12" FontFamily="Gisha"
                                                                Text="Reward:"
                                                                Margin="0,0,5,0"/>

                                        <core:OutlinedTextBlock Fill="White" Stroke="Black" StrokeThickness="4" StrokeOpacity="0.75"
                                                                FontSize="12" FontFamily="Gisha"
                                                                Margin="0,0,2,0"
                                                                Text="{Binding RewardGold}"/>
                                        <Image Source="../../Resources/gold_coin.png"
                                               Height="12" Width="12"
                                               Margin="0,0,5,0"/>

                                        <core:OutlinedTextBlock Fill="White" Stroke="Black" StrokeThickness="4" StrokeOpacity="0.75"
                                                                FontSize="12" FontFamily="Gisha"
                                                                Margin="0,0,2,0"
                                                                Text="{Binding RewardSilver}"/>
                                        <Image Source="../../Resources/silver_coin.png"
                                               Height="12" Width="12"/>
                                    </StackPanel>
                                </StackPanel>
                            </CheckBox.ToolTip>
                        </CheckBox>
                    </DataTemplate>
                </ItemsControl.ItemTemplate>

            </ItemsControl>
            
        </Grid>
    </Border>
</UserControl>
